<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/brick-html-tags" prefix="h" %>
<html>
<head>
<base target="_self">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>文件上传</title>
<h:header/>
</head>
<body>

<SCRIPT LANGUAGE="JavaScript">
	function addFileInput(obj) {
		obj.insertAdjacentHTML("beforeBegin", "<input type=\"file\" name=\"f1\" size=\"36\" onchange=\"javascript:validFileName(this)\"/><input type=\"button\" style=\"width:37px;height:20px\" value=\"去除\" onclick=\"javascript:removeFileInput(this)\"/><br>");
	}

	function removeFileInput(obj) {
		obj.previousSibling.removeNode();
		obj.nextSibling.removeNode();
		obj.removeNode();
	}
	
	function validFileName(obj) {
		var v = obj.value;
		var os = document.getElementsByName('f1');
		for (var i = 0; i < os.length; i ++) {
			if (obj != os[i] && v == os[i].value) {
				alert("您选择的文件重复,请确认是否一定要上传两个相同的文件");
				break;
			}
		}
	}
</SCRIPT>
<form id="upload" name="upload" action="${WEB_APP_CONTEXT}/fileupload/upload" enctype="multipart/form-data" method="POST">
	<input type="hidden" name="globe.fileupload.objectid" value="${param.objectId}"/>
	<input type="hidden" name="globe.fileupload.objecttype" value="${param.objectType}"/>
	<input type="hidden" name="globe.fileupload.beanid" value="${param.beanId}"/>
	<input type="hidden" name="uploaderId" value="${param.uploaderId}"/><br>
	<center>
		<input type="file" name="f1" size="42" onchange="javascript:validFileName(this)"/><br>
		<input type="button" value="添加" onclick="javascript:addFileInput(this)"/><input type="submit" value="上传"/>
	</center>
</form>

</body>
</html>